var fileToPublish = "${flaPath}";
var publishProfile = "${profilePath}";
var closeFLA = ${closeFLA};

clearPanels();

if(fl.fileExists(fileToPublish))
{
	dom = fl.openDocument(fileToPublish);
	
	var importedProfile = dom.importPublishProfile(publishProfile);
	if(importedProfile != -1)
	{
		log("Publishing " + fileToPublish);
		dom.publish();
		dom.deletePublishProfile(importedProfile);
	}
	else
	{
		error("Flash tried to access an invalid profile (publish.jsfl)");
	}
	
	
	if(closeFLA)
	{
		dom.close(false);
	}
}
else
{
	error("FLA [" + fileToPublish + "] does not exist (publish.jsfl)");
}

